package com.itheima.d01_properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Test {
    public static void main(String[] args) throws IOException {
        //读取users.properties文件
        //1.创建Properties对象
        Properties properties = new Properties();
        //2.将指定属性文件加载到Properties对象中
        properties.load(new FileInputStream("day12_properties_xml_log\\src\\com\\itheima\\d01_properties\\users.properties"));
        //3.获取集合
        //方式1：键找值
        System.out.println(properties.getProperty("admin"));
        System.out.println(properties.getProperty("liergouzi"));
        System.out.println(properties.getProperty("zhangsan"));
        System.out.println("===================");
        //方式2：键值对
        Set<Map.Entry<Object, Object>> entrySet = properties.entrySet();
        for (Map.Entry<Object, Object> entry : entrySet) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }
        System.out.println("===================");
        //方式3：lambda
        properties.forEach((k,v)-> System.out.println(k+"="+v));
    }
}
